package com.kwshare.system.controller;

import com.kwshare.common.api.RemoteUserService;
import com.kwshare.common.core.domain.Response;
import com.kwshare.common.core.domain.auth.LoginUser;
import com.kwshare.system.service.impl.UserRoleServiceImpl;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 用户角色
 *
 * @author yangjing
 */
@RestController
@RequestMapping("/userRole")
public class UserRoleController {

    @Resource
    private UserRoleServiceImpl userRoleService;

    @Resource
    private RemoteUserService remoteUserService;

    @GetMapping("getRoles")
    public Response<?> getRoles(String username){
        Response<LoginUser> userInfo = remoteUserService.userInfo(username);
        List<Long> roles = userRoleService.selectRolesByUserId(userInfo.getData().getUser().getId());
        return Response.ok(roles);
    }
}
